#include <iostream> 
#include <ctime> 
#include <cstdlib>

using namespace std;

int rand_lim(int limit) 
{ 
    //return a random number between 0 and limit inclusive.  
        
    int divisor = RAND_MAX/(limit+1);    
    int retval;      
    do 
    {
               //srand(time(NULL));           
               retval = rand() / divisor;     
    }
    while (retval > limit);      
                       
    return retval; 
} 

int main()
{
	int board[9][9][2]; //creates a 9*9 matrix or a 2d array.

	for(int i=0; i<9; i++)    //This loops on the rows.
	{
		for(int j=0; j<9; j++) //This loops on the columns
		{
                for(int k=0; k<2; k++) //This loops on food and production.
                {
                        int food, prod;
                        if (k==0)
                        {
                                 food = rand_lim(2);
                                 board[i][j][k] = food;         
                        } 
                        else if (k==1)
                        {
                                 prod = rand_lim(2);
                                 board[i][j][k] = prod;
                        }       
                        
                }
		}
	}
    
    cout << endl;
    
	for(int i=0; i<9; i++)    //This loops on the rows.
	{
		for(int j=0; j<9; j++) //This loops on the columns.
		{
			for(int k=0; k<2; k++) //This loops on the heights.
            {    
                    cout << board[i][j][k]  << "  ";
            }       
            cout << "\t"; 
		}
		cout << "\n";
	}
	int gamma;
	cin >> gamma;
return 0;
}
